# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
from main.models import Unit
from oets.userprofile.fields import AutoOneToOneField

class Profile(models.Model):
    user = AutoOneToOneField(User, related_name='profile', verbose_name=('User'), primary_key=True)
    unit_access = models.ManyToManyField(Unit, blank=True, null=True, verbose_name = 'Подразделение')

    def get_unit(self):
        return self.unit_access.all()[0].id

    def get_units(self):
        return self.unit_access.all()

